package in.muton.edushare.pages.user;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.link.Link;

import com.edushare.common.constants.ApplicationConstants;

public class CreateGroup extends UserBase {
	
	public CreateGroup(PageParameters params) {
		super(params);
		if(params.getString("v", "list").equalsIgnoreCase("create")){
			loadCreate();
		}else{
			loadList();
		}
		
		
	}
	
	private void loadCreate(){
		final CreateGroupForm groupList = new CreateGroupForm("activePanel");
		add(groupList);
		final WebMarkupContainer newGroupCont = new WebMarkupContainer("newGroupCont");
		add(newGroupCont);
		Link<Void> createAGroup = new Link<Void>("createAGroup") {
			
			private static final long serialVersionUID = 3678469806770641676L;
			
			@Override
			public void onClick() {}
		};
		newGroupCont.add(createAGroup);
		newGroupCont.setVisible(false);
	}
	
	private void loadList(){
		final GroupListPanel groupList = new GroupListPanel("activePanel", CreateGroup.this);
		add(groupList);
		final WebMarkupContainer newGroupCont = new WebMarkupContainer("newGroupCont");
		add(newGroupCont);
		Link<Void> createAGroup = new Link<Void>("createAGroup") {

			private static final long serialVersionUID = 3678469806770641676L;

			@Override
			public void onClick() {
				groupList.replaceWith(new CreateGroupForm("activePanel"));
				newGroupCont.setVisible(false);				
			}
		};
		newGroupCont.add(createAGroup);
	}
	
	
	@Override
	public String getActivePage() {
		return "createGroup";
	}

	@Override
	public String getPageTitle() {
		return "Start A New Group | " + ApplicationConstants.APPLICATION_NAME;
	}

	@Override
	public String getUserRole() {
		return "";
	}

}
